﻿@using EvertonApp.AdminWeb.Extensions
@model EvertonApp.AdminWeb.Models.ComentarioModel

<script type="text/javascript">
    var jQuery = {};
</script>

<center>
<div id="divGridComentarios">
    @if (@Model.Comentarios != null && @Model.Comentarios.Count() > 0)
    {
        WebGrid grid = new WebGrid(defaultSort: "FechaCreacion", rowsPerPage: 8, ajaxUpdateContainerId: "divGridComentarios");
        grid.Bind(Model.Comentarios, autoSortAndPage: true, rowCount: Model.Comentarios.Count());
        @grid.GetHtml(
            fillEmptyRows: false,
            tableStyle: "table table-striped table-bordered table-condensed",
            mode: WebGridPagerModes.All,
            //firstText: "<< Primera",
            //previousText: "< Anterior",
            //nextText: "Siguiente >",
            //lastText: "Última >>",
            columns: new[]{
                //grid.Column("IdComentario",header: "Nº Comentario", canSort: false),
                grid.Column("Descripcion",header: "Comentario", canSort: false),
                grid.Column("FechaCreacion",header: "Fecha", canSort: false, format: @<text> @DateFormat.Convert(@item.FechaCreacion) </text> ),
                grid.Column("CreadoPor",header: "Autor", canSort: false, format: @<text> @item.CreadoPor.Nombre </text>), 
                grid.Column("",header: "Acciones", format:@<text>
                                                                @Ajax.ActionLink("Eliminar", "DeleteComentario", "Post", new { idComentario = item.IdComentario }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divGridComentarios", OnComplete="limpiarCampos();" })
                                                                @Ajax.ActionLink("Editar", "EditComentario", "Post", new { idComentario = item.IdComentario }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup();limpiarCampos();"})
                                                           </text> )}
        )
    }
    else
    {
        <label>No se han encontrado comercios.</label>
    }
</div>
</center> 
